/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Khalid
 */
@Entity
@Table(name = "lign_cmd")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LignCmd.findAll", query = "SELECT l FROM LignCmd l"),
    @NamedQuery(name = "LignCmd.findByIdCmd", query = "SELECT l FROM LignCmd l WHERE l.lignCmdPK.idCmd = :idCmd"),
    @NamedQuery(name = "LignCmd.findByIdPdt", query = "SELECT l FROM LignCmd l WHERE l.lignCmdPK.idPdt = :idPdt"),
    @NamedQuery(name = "LignCmd.findByIsCalc", query = "SELECT l FROM LignCmd l WHERE l.lignCmdPK.isCalc = :isCalc"),
    @NamedQuery(name = "LignCmd.findByPrixVendu", query = "SELECT l FROM LignCmd l WHERE l.prixVendu = :prixVendu"),
    @NamedQuery(name = "LignCmd.findByQte", query = "SELECT l FROM LignCmd l WHERE l.qte = :qte"),
    @NamedQuery(name = "LignCmd.findByTotal", query = "SELECT l FROM LignCmd l WHERE l.total = :total"),
    @NamedQuery(name = "LignCmd.findByMarge", query = "SELECT l FROM LignCmd l WHERE l.marge = :marge"),
    @NamedQuery(name = "LignCmd.findByLargeur", query = "SELECT l FROM LignCmd l WHERE l.largeur = :largeur"),
    @NamedQuery(name = "LignCmd.findByHauteur", query = "SELECT l FROM LignCmd l WHERE l.hauteur = :hauteur")})
public class LignCmd implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected LignCmdPK lignCmdPK;
    @Basic(optional = false)
    @Column(name = "prix_vendu")
    private double prixVendu;
    @Column(name = "qte")
    private Integer qte;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "total")
    private Double total;
    @Column(name = "marge")
    private Double marge;
    @Column(name = "largeur")
    private Double largeur;
    @Column(name = "hauteur")
    private Double hauteur;
    @JoinColumn(name = "id_pdt", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Produit produit;
    @JoinColumn(name = "id_cmd", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Commande commande;

    public LignCmd() {
    }

    public LignCmd(LignCmdPK lignCmdPK) {
        this.lignCmdPK = lignCmdPK;
    }

    public LignCmd(LignCmdPK lignCmdPK, double prixVendu) {
        this.lignCmdPK = lignCmdPK;
        this.prixVendu = prixVendu;
    }

    public LignCmd(int idCmd, int idPdt, short isCalc) {
        this.lignCmdPK = new LignCmdPK(idCmd, idPdt, isCalc);
    }

    public LignCmdPK getLignCmdPK() {
        return lignCmdPK;
    }

    public void setLignCmdPK(LignCmdPK lignCmdPK) {
        this.lignCmdPK = lignCmdPK;
    }

    public double getPrixVendu() {
        return prixVendu;
    }

    public void setPrixVendu(double prixVendu) {
        this.prixVendu = prixVendu;
    }

    public Integer getQte() {
        return qte;
    }

    public void setQte(Integer qte) {
        this.qte = qte;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    public Double getMarge() {
        return marge;
    }

    public void setMarge(Double marge) {
        this.marge = marge;
    }

    public Double getLargeur() {
        return largeur;
    }

    public void setLargeur(Double largeur) {
        this.largeur = largeur;
    }

    public Double getHauteur() {
        return hauteur;
    }

    public void setHauteur(Double hauteur) {
        this.hauteur = hauteur;
    }

    public Produit getProduit() {
        return produit;
    }

    public void setProduit(Produit produit) {
        this.produit = produit;
    }

    public Commande getCommande() {
        return commande;
    }

    public void setCommande(Commande commande) {
        this.commande = commande;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (lignCmdPK != null ? lignCmdPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LignCmd)) {
            return false;
        }
        LignCmd other = (LignCmd) object;
        if ((this.lignCmdPK == null && other.lignCmdPK != null) || (this.lignCmdPK != null && !this.lignCmdPK.equals(other.lignCmdPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.LignCmd[ lignCmdPK=" + lignCmdPK + " ]";
    }
    
}
